de1fa976680466b464e121c86266fe8dffb84d8b,components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/MongoDbDynamicityTest.java,MongoDbDynamicityTest,testInsertDynamicityEnabledDBOnly,#,59
Before Change
@Test
public void testInsertDynamicityEnabledDBOnly() {
assertEquals(0, testCollection.count());
mongo.getDB("otherDB").dropDatabase();
db.getCollection("otherCollection").drop();
assertFalse("The otherDB database should not exist", mongo.getDatabaseNames().contains("otherDB"));
String body = "{\"_id\": \"testInsertDynamicityEnabledDBOnly\", \"a\" : \"1\"}";
Map<String, Object> headers = new HashMap<String, Object>();
headers.put(MongoDbConstants.DATABASE, "otherDB");
Object result = template.requestBodyAndHeaders("direct:dynamicityEnabled", body, headers);
DBCollection dynamicCollection = mongo.getDB("otherDB").getCollection(testCollection.getName());
DBObject b = dynamicCollection.findOne("testInsertDynamicityEnabledDBOnly");
assertNotNull("No record with 'testInsertDynamicityEnabledDBOnly' _id", b);
b = testCollection.findOne("testInsertDynamicityEnabledDBOnly");
After Change
@Test
public void testInsertDynamicityEnabledDBOnly() {
assertEquals(0, testCollection.count());
mongo.getDatabase("otherDB").drop();
db.getCollection("otherCollection").drop();
assertFalse("The otherDB database should not exist",
StreamSupport.stream(mongo.listDatabaseNames().spliterator(), false)
.anyMatch("otherDB"::equals));
String body = "{\"_id\": \"testInsertDynamicityEnabledDBOnly\", \"a\" : \"1\"}";
Map<String, Object> headers = new HashMap<String, Object>();
headers.put(MongoDbConstants.DATABASE, "otherDB");
Object result = template.requestBodyAndHeaders("direct:dynamicityEnabled", body, headers);
MongoCollection<BasicDBObject> dynamicCollection = mongo.getDatabase("otherDB").getCollection(testCollection.getNamespace().getCollectionName(), BasicDBObject.class);
DBObject b = dynamicCollection.find(new BasicDBObject("_id", "testInsertDynamicityEnabledDBOnly")).first();
assertNotNull("No record with 'testInsertDynamicityEnabledDBOnly' _id", b);
b = testCollection.find(new BasicDBObject("_id", "testInsertDynamicityEnabledDBOnly")).first();